export function selectOrder(val, sel_obj) { //val 要被筛选的数据   obj 筛选的条件
    let arr = [] //承接符合筛选后的数据
    let obj = JSON.parse(JSON.stringify(sel_obj))
    let start = new Date(obj.date1).getTime()
    let end = new Date(obj.date2).getTime()

    obj.time = end - start
    delete obj.date1
    delete obj.date2
    console.log(obj)
    for (let i = 0; i < val.length; i++) {
        let flag = true; //控制开关
        for (let key in obj) {
            if (obj[key] !== "") {
                if (key === "time") {
                    let now = new Date(val[i].time).getTime()
                    console.log(start, end, now)
                    if (end < now || now < start) {
                        flag = false
                    }
                } else if (key === 'ord_num') {
                    if (val[i].ord_num !== obj[key]) {
                        flag = false
                    }
                } else if (key === 'state') {
                    if (val[i].state != obj[key]) {
                        flag = false
                    }
                } else if (key === 'username' || key === 'game') {
                    if (val[i][key].indexOf(obj[key]) === -1) {
                        flag = false
                    }
                }
            }
        }
        if (flag) {
            arr.push(val[i])
        }
    }
    return arr

    // const sel_key = Object.keys(sel_obj)

    // return val.filter(item => {
    //     return sel_key.every(key => {
    //         if (key === 'data1' && key === 'data2') {
    //             let start = new Date(obj.data1).getTime()
    //             let end = new Date(obj.data2).getTime()
    //             if (start <= (new Date(val[i].time).getTime()) <= end) {
    //                 return true
    //             }
    //         } else if (!sel_obj[key].length) {
    //             return true
    //         }
    //         return !!~sel_obj[key].indexOf(item[key])
    //     })
    // })
}